package edu.scau.hot.service.impl;

import edu.scau.hot.entity.HotRoom;
import edu.scau.hot.mapper.HotRoomMapper;
import edu.scau.hot.service.IHotRoomService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (HotRoom)表服务实现类
 *
 * @author PaperEasyCode
 * @since 2022-03-01 14:34:09
 */
@Service("hotRoomService")
public class HotRoomServiceImpl implements IHotRoomService{
    @Resource
    private HotRoomMapper hotRoomMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param roomId 主键
     * @return 实例对象
     */
    @Override
    public HotRoom queryById(Integer roomId) {
        return this.hotRoomMapper.queryById(roomId);
    }

    /**
     * 查询所有数据
     *
     * @param hotRoom 筛选条件
     * @return 查询结果
     */
    @Override
    public List<HotRoom> queryAll(HotRoom hotRoom) {
        return this.hotRoomMapper.queryAll(hotRoom);
    }

    /**
     * 新增数据
     *
     * @param hotRoom 实例对象
     * @return 实例对象
     */
    @Override
    public HotRoom insert(HotRoom hotRoom) {
        this.hotRoomMapper.insert(hotRoom);
        return hotRoom;
    }

    /**
     * 修改数据
     *
     * @param hotRoom 实例对象
     * @return 实例对象
     */
    @Override
    public HotRoom update(HotRoom hotRoom) {
        this.hotRoomMapper.update(hotRoom);
        return this.queryById(hotRoom.getRoomId());
    }

    /**
     * 通过主键删除数据
     *
     * @param roomId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer roomId) {
        return this.hotRoomMapper.deleteById(roomId) > 0;
    }
}
